/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import dto.Payment;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Timmy
 */
public class ModelConverter {
    
    static  DecimalFormat df=new DecimalFormat("#.00"); 
    static DateFormat tf = new SimpleDateFormat("mm/dd/yyyy");
    public static PaymentModel ConvertPaymentModel(Payment dto)
    {
        PaymentModel payModel = new PaymentModel();
        payModel.setAmount(df.format(dto.getAmount()));
        payModel.setApproveDate(null);
        payModel.setApproveDate(tf.format(dto.getApproveDate()));
        payModel.setPayDate(tf.format(dto.getPayDate()));
        payModel.setUserName(dto.getId().getUserName());
        payModel.setPayName(dto.getId().getPayName());
        switch (dto.getPayStatus())
        {
            case 0: payModel.setPayStatus("Pending");break;
            case 1: payModel.setPayStatus("Submited");break;
            case 2: payModel.setPayStatus("Approved");break; 
        }
        switch(dto.getId().getPayType())
        {
            case 1: payModel.setPayType("Conference");break; 
            case 2: payModel.setPayType("Conference Item");break; 
        }
        return payModel; 
    }
    
    public static List<PaymentModel> ConvertPaymentList(List<Payment> dto)
    {
        if (dto == null)
        {
            return new ArrayList<>(); 
        }
        List<PaymentModel> models = new ArrayList<>();
        for (Payment oneDto: dto)
        {
            models.add(ModelConverter.ConvertPaymentModel(oneDto));
        }
        return models; 
    }
}
